package com.chujian.framework.sync.aop;

import com.chujian.framework.sync.SyncDataDispatcher;
import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.AfterReturningAdvice;
import org.springframework.beans.factory.annotation.Autowired;

import java.lang.reflect.Method;

/**
 * AOP方法拦截器
 */
@Slf4j
public class SyncMethodAdvice implements AfterReturningAdvice {

    @Autowired
    private SyncDataDispatcher dispatcher;

    @Override
    public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {
        dispatcher.dispatch(target, method, args, returnValue);
    }
}